package com.hehao.producer;

import com.hehao.config.RabbitConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MessageSenderService {

    private final AmqpTemplate myRabbitMQ;
    private final RabbitTemplate rabbitTemplate;

    public MessageSenderService(AmqpTemplate myRabbitMQ, RabbitTemplate rabbitTemplate) {
        this.myRabbitMQ = myRabbitMQ;
        this.rabbitTemplate = rabbitTemplate;
    }


    public void send(String routingKey, String message) {
        rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE, routingKey, message);
    }
}